namespace DeviceRepairWorkflow.Api.Models;

public class WorkflowInstance
{
    public int Id { get; set; }
    public int RepairRequestId { get; set; }
    public RepairRequest RepairRequest { get; set; } = null!;
    public string ElsaWorkflowInstanceId { get; set; } = string.Empty;
    public string CurrentStep { get; set; } = string.Empty;
    public WorkflowStatus Status { get; set; } = WorkflowStatus.Running;
    public DateTime CreatedAt { get; set; } = DateTime.Now;
    public DateTime? CompletedAt { get; set; }
    public string? CreatedBy { get; set; }
    public string? Data { get; set; } // JSON data for workflow variables
    public List<WorkflowStep> Steps { get; set; } = new();
    
    // Decision data
    public bool? IsExternalRepair { get; set; }
    public int? ExternalVendorId { get; set; }
    public ExternalVendor? ExternalVendor { get; set; }
    
    // Repair details
    public string? RepairContent { get; set; }
    public int? RepairHours { get; set; }
    public decimal? RepairCost { get; set; }
    public string? RepairNotes { get; set; }
    
    // Approval data
    public bool? IsApproved { get; set; }
    public string? ApprovalNotes { get; set; }
    public string? ApprovedBy { get; set; }
    public DateTime? ApprovedAt { get; set; }
}

public class WorkflowStep
{
    public int Id { get; set; }
    public int WorkflowInstanceId { get; set; }
    public WorkflowInstance WorkflowInstance { get; set; } = null!;
    public string StepName { get; set; } = string.Empty;
    public string StepType { get; set; } = string.Empty;
    public StepStatus Status { get; set; } = StepStatus.Pending;
    public DateTime CreatedAt { get; set; } = DateTime.Now;
    public DateTime? CompletedAt { get; set; }
    public string? CompletedBy { get; set; }
    public string? Data { get; set; } // JSON data for step-specific data
    public int Order { get; set; }
}

public enum WorkflowStatus
{
    Running,
    Completed,
    Cancelled,
    Failed
}

public enum StepStatus
{
    Pending,
    InProgress,
    Completed,
    Skipped,
    Failed
} 